<template>
  <div class="top-container">
    <div class="left-box">
      <div class="icon-wrapper">
        <span class="iconfont icon-home"></span>
        <span class="iconfont icon-sami-select"></span>
        <span class="iconfont icon-full-screen"></span>
      </div>
      <div class="history-wrapper">
        <span class="iconfont icon-arrow-lift"></span>
        <span class="iconfont icon-arrow-right"></span>
      </div>
    </div>
    <div class="right-box">
      <div class="el-input el-input--small el-input--prefix">
        <input
          type="text"
          autocomplete="off"
          placeholder="搜索"
          class="el-input__inner"
          @keyup.enter="toResult"
          v-model="inputValue"
        />
        <span class="el-input__prefix">
          <i class="el-input__icon el-icon-search"></i>
        </span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "top",
  data() {
    return {
      query: "",
      inputValue: ""
    };
  },
  methods: {
    toResult() {
      //非空判断 如果用户什么都没有输入就不用跳转 提示用户输入就行
      if (this.inputValue == "") {
        this.$message.warning("请输入内容");
      } else {
        //否则去搜索页并且携带数据
        this.$router.push("/result?q=" + this.inputValue);
      }
    }
  }
};
</script>

<style scoped></style>
